//
//  MainViewController.swift
//  6.2Weibo
//
//  Created by 邓金明 on 16/6/2.
//  Copyright © 2016年 邓金明. All rights reserved.
//

import UIKit

class MainViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()

        addViewControllers()
        
    }


    func addChildViewController(controller: UIViewController,title:String,imageName:String){
        
        let nav = UINavigationController(rootViewController: controller)
        
        controller.title = title

        let selectedImageName = "\(imageName)_selected"
        
        controller.tabBarItem.image = UIImage(named: imageName)
        
        controller.tabBarItem.selectedImage = UIImage(named: selectedImageName)
        
        addChildViewController(nav)
        
        
    }
    
    
    func addViewControllers(){
    
        
        let home = HomeViewController()
        addChildViewController(home, title: "主页", imageName: "tabbar_home")
        
        let message = MessageViewController()
        addChildViewController(message, title: "消息", imageName: "tabbar_message_center")
        
        let discover = DiscoverViewController()
        addChildViewController(discover, title: "发现", imageName: "tabbar_discover")
        
        let profile = ProfileViewController()
        addChildViewController(profile, title: "我", imageName: "tabbar_profile")
        
        
        
    }

}
